/* 
 * cms，一个基于J2EE架构内容管理系统
 * Copyright © GrayRabbit Co., Ltd. All rights reserved.
 * Department:运营department
 * 更多信息请访问：
 * http://code.google.com/p/gray-rabbit-cms/
 */
package org.grayrabbit.cms.action.site;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.grayrabbit.cms.action.common.BaseAction;
import org.grayrabbit.cms.constant.ConstantOperCode;
import org.grayrabbit.cms.constant.ConstantWebApp;
import org.grayrabbit.cms.constant.DBInitId;
import org.grayrabbit.cms.constant.DictionaryStaticValues;
import org.grayrabbit.cms.constant.ConstantEnum.Module;
import org.grayrabbit.cms.constant.ConstantEnum.OperAct;
import org.grayrabbit.cms.entity.Admin;
import org.grayrabbit.cms.entity.Category;
import org.grayrabbit.cms.entity.Dictionary;
import org.grayrabbit.cms.entity.Site;
import org.grayrabbit.cms.entity.Survey;
import org.grayrabbit.cms.entity.Topic;
import org.grayrabbit.cms.entity.Vote;
import org.grayrabbit.cms.service.category.CategoryService;
import org.grayrabbit.cms.service.category.impl.CategoryCache;
import org.grayrabbit.cms.service.dictionary.DictionaryService;
import org.grayrabbit.cms.service.plugins.SurveyService;
import org.grayrabbit.cms.service.plugins.VoteService;
import org.grayrabbit.cms.service.site.SiteService;
import org.grayrabbit.cms.service.system.AdminOperRelaService;
import org.grayrabbit.cms.service.system.RoleOperRelaService;
import org.grayrabbit.cms.service.topic.TopicService;
import org.grayrabbit.cms.util.DateUtil;
import org.grayrabbit.cms.util.FilePathSptUtil;
import org.grayrabbit.cms.util.FileUtil;
import org.grayrabbit.cms.vo.site.SiteBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import org.grayrabbit.dao.util.Page;

/**
 * <b>SiteAction</b> Struts2 action�?





 * @version 1.0,创建时间:2011-05-16 15:11:17 
 */
@Controller
@Scope("prototype")
@Results( {
		@Result(name = "reload", type = "redirect", location = "category-list"),
		@Result(name = "input", type = "dispatcher", location = "site-input.jsp")
		}
		)
public class SiteAction extends BaseAction<SiteBean> {
	private static final long serialVersionUID = -1L;
	public static final String STATUS = "status";
	private static final String SPT = File.separator;
	//Service接口接入
	@Autowired
	@Qualifier("siteServiceImpl")
	private SiteService siteService;
	@Autowired
	@Qualifier("dictionaryServiceImpl")
	private DictionaryService dictionaryService;
	@Autowired
	@Qualifier("categoryServiceImpl")
	private CategoryService categoryService;
	@Autowired
	@Qualifier("topicServiceImpl")
	private TopicService topicService;
	@Autowired
	@Qualifier("voteServiceImpl")
	private VoteService voteService;
	@Autowired
	@Qualifier("surveyServiceImpl")
	private SurveyService surveyService;
	@Autowired
	@Qualifier("roleOperRelaServiceImpl")
	private RoleOperRelaService roleOperRelaService;
	@Autowired
	@Qualifier("adminOperRelaServiceImpl")
	private AdminOperRelaService adminOperRelaService;
	
	//VO对象，由前端页面数据组装
	private SiteBean site;
	
	private String siteName;
	
	private String stname;
	
	private String flag;
	
	private String oldSimpleName;
	
	private List<Dictionary> dicIsVirtualHosting;
	
	private List<Dictionary> dicArea;
	
	private String countryArea;
	
	private String provinceArea;
	
	private String cityArea;

	private String pic;
	
	private File upload;
	
	private String picTemp;
	
	private String url;
	
	private String siteLogoDbPath;
	
	private String siteBannerDbPath;
	
	private String siteLogoPhysicalPath;
	
	private String siteBannerPhysicalPath;

	private String upType;
	
	//分页对象
	private Page<Site> page = new Page<Site>(MAX_PAGE_NUM,true);
	
	/*
	 * return分页对象，默认实例化。如：page.pageNu=2,将更新相应的对象property
	 */
	public Page<Site> getPage() {
		return page;
	}
	//接收前端form,url提交参数组装成分页property
	public void setPage(Page<Site> page) {
		this.page = page;
	}
	
	/**
	 * 在执行（struts2的action调用时）list()方法前执行本方法
	 */
	public void prepareList(){
		prepareModel();
	}
	
	/**
	 * 在执行任何其它action方法（struts2的action调用时）前执行本方法
	 */
	public void prepare(){
		if(site==null){
			site = new SiteBean();
		}
	}
	/**
	 * 实现ModelDriven的接口简例前端页的bean组装写法,
	 *  如：
	 *	<pre>
	 *		<code> name="user.userName"</code>
	 *	改写成：
	 *		<code> name="userName"</code>
	 *	action实例中，会自动组成user成员变量
	 *	</pre>
	 */
	public SiteBean getModel() {
		return site;
	}
	@Override
	protected void prepareModel(){
		if(site != null && StringUtils.isNotBlank(site.getSiteId())){
			site = (SiteBean)dozer.map(siteService.getSite(site.getSiteId()),SiteBean.class);
		}
	}
	/**
	 * 判断站点中是否包含栏目、专题
	 * @return
	 */
	@Action(value="site-checksite")
	public String checkSite(){
		String text = "";
		List<Category> clist = categoryService.findBySiteId(key[0]);
		if(clist.size()>0){
			text = "havacat";
		}
		List<Topic> tlist = topicService.findBySiteId(key[0]);
		if(tlist.size()>0){
			text = "havatop";
		}
		List<Vote> vlist = voteService.findBySiteId(key[0]);
		if(vlist.size()>0){
			text = "havavote";
		}
		List<Survey> slist = surveyService.findBySiteId(key[0]);
		if(slist.size()>0){
			text = "havasurvey";
		}
		return renderText(text);
	}
	/**
	 * 删除<b>Site</b>记录的方法，成员变量<b>key</b>为主键的String数组，以主键方式进行删作
	 * 删除成功后，返回"reload"，然后跳转到site-list.action
	 */
	@Override
	@Action(value="site-delete",
			results={@Result(name="reload",type="redirectAction",params={"actionName","site-default?flag=delok"})}
			)
	public String delete(){
		siteService.delete(key);
		roleOperRelaService.deleteObjectAuth(key,ConstantOperCode.AUTH_SITE_TYPE);
		adminOperRelaService.deleteObjectAuth(key,ConstantOperCode.AUTH_SITE_TYPE);
		for(int i=0;i<key.length;i++){
			addLog(Module.SITE.getValue(),OperAct.DEL.getValue(),key[i]);
			saveMemoryHandle(key[i]);
		}
		
		return RELOAD;
	}
	
	@Action(value="site-default")
	public String defaultpage(){
		return SUCCESS;
	}
	
	/**
	 * Site的列表方法，通过成员变量<b>page�?{insClassName}</b>调用service接口，更新page
	 * 执行成功后，将映射到site-list.jsp页面
	 */
	@Override
	public String list(){
		siteService.list(page,site);
		return SUCCESS;
	}
	
	/**
	 * 判断站点跳转页面(启用-编辑页面、禁用-启用界面)
	 * @return
	 */
	@Action(value="site-gosite",
			results={@Result(name="reload",type="redirectAction",params={"actionName","site-input?site.siteId=${site.siteId}"}),
			 @Result(name="status",type="redirectAction",params={"actionName","status-but?site.siteId=${site.siteId}"})})
	public String goSite(){
		if(site.getSiteStatus() == true){
			return RELOAD;
		}else{
			return STATUS;
		}
	}
	
	/**
	 * Site的新增与编辑的方法执行成功能
	 * 将映射到site-input.jsp
	 */
	@Action(value="site-input")
	public String input(){
		prepareModel();	
		if(dictionaryService.getDictionaryListByTypeCode(DictionaryStaticValues.IS_VIRTUALHOSTING)!=null){
			dicIsVirtualHosting = dictionaryService.getDictionaryListByTypeCode(DictionaryStaticValues.IS_VIRTUALHOSTING);
		}
		if(dictionaryService.getParentDictionaryList(DictionaryStaticValues.AREA)!=null){
			dicArea = dictionaryService.getDictionaryListDictionaryKey(DictionaryStaticValues.CHINA, DictionaryStaticValues.AREA);
		}
		setSessionValue("THEME_VISIT_URL", FilePathSptUtil.THEME_VISIT_URL);
		return INPUT;
	}
	
	/**
	 * save or update Site的方法，将成员property site转成Site实例，执行保存；
	 * 执行成功后，返回"reload"，然后跳转到site-list.action
	 */
	@Override
	@Action(value="site-save",
			results={@Result(name="reload",type="redirectAction",params={"actionName","site-default"})}
		)
	public String save(){
		Site obj = (Site) dozer.map(site, Site.class);
		if(!StringUtils.isNotBlank(obj.getSiteId())){
			obj.setSiteId(null);
		}
		Admin admin = getCurrentAdmin();
		if(!StringUtils.isNotBlank(site.getSiteId())){
			if(admin != null){
				obj.setCreateLoginName(admin.getLoginName());
				obj.setCreateRealName(admin.getRealName());
			}
			obj.setCreateTime(new Date());
		}else{
			obj.setUpdateTime(new Date());
			if(admin != null){
				obj.setUpdateLoginName(admin.getLoginName());
				obj.setUpdateRealName(admin.getRealName());
			}
		}
		Boolean ss = new Boolean(true);
		obj.setSiteStatus(ss);
		String siteTheme = site.getSiteTheme();
		if(StringUtils.isBlank(siteTheme)){
			obj.setSiteIndexTpl("/theme/default/index.tpl");
		}else{
			obj.setSiteIndexTpl("/theme/"+siteTheme+"/index.tpl");
		}
		String sitename = site.getSiteName().trim();
		obj.setSiteName(sitename);
		String sitesimpname = site.getSiteShortName().trim();
		obj.setSiteShortName(sitesimpname);
		
		if(StringUtils.isNotBlank(cityArea)){
			obj.setArea(cityArea);
		}else if(StringUtils.isNotBlank(provinceArea)){
			obj.setArea(provinceArea);
		}
		else if(StringUtils.isNotBlank(countryArea)){
			obj.setArea(countryArea);
		}
		if(StringUtils.isNotBlank(obj.getLogo())) {
			File file = new File(FilePathSptUtil.UPLOAD_ROOT_PATH + obj.getLogo());
			deleteExitsFile(file);
		}
		if(StringUtils.isNotBlank(siteLogoDbPath)){
			obj.setLogo(siteLogoDbPath);
		}
		if(StringUtils.isNotBlank(siteBannerDbPath)){
			obj.setBanner(siteBannerDbPath);
		}
		/*String filename=null;
		pic=picTemp;
		if(StringUtils.isNotBlank(pic)){
			 filename=upload(pic);
			 obj.setLogo(FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					 FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+filename);
		}*/
		
		siteService.save(obj);
		//创建站点时给其赋予相应的权限
		if(StringUtils.isBlank(site.getSiteId())){
			addObjectDistributeAuthCode(obj.getSiteId(),ConstantOperCode.AUTH_SITE_TYPE,ConstantOperCode.SITE_SITE);
			addLog(Module.SITE.getValue(),OperAct.ADD.getValue(),obj.getSiteId());
		}else{
			addLog(Module.SITE.getValue(),OperAct.EDIT.getValue(),site.getSiteId());
		} 
		return RELOAD;
	}
	private void saveMemoryHandle(String CurrentSiteId){
		if(StringUtils.isBlank(CurrentSiteId))
			return ;
		CategoryCache.removeSiteCategoriesAndFlagInfo(CurrentSiteId);
		CategoryCache.removeAuthCatsAndFlagbySiteIds(CurrentSiteId);		
	}
	private String upload(String pic){
		SimpleDateFormat formater = new SimpleDateFormat("yyyyMMddhhmmssSSSS");
		String filename=formater.format(new Date());
		String fileExtend = pic.substring(pic.lastIndexOf(".")+1,pic.length());
		String root= FilePathSptUtil.UPLOAD_ROOT_PATH+FilePathSptUtil.UPLOAD_CMS+SPT+FilePathSptUtil.CMS_LOGO+SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM");
		String fullName=filename+"."+fileExtend;
		String dstPath = root+SPT+fullName;	//全路径
		File dirFile = new File(root);
		boolean isDir = dirFile.isDirectory();
		if(!isDir){//目录不存在则先建目录
			try{
				dirFile.mkdirs();
			}catch (Exception e) {
				File delFile = new File(root
						+SPT +fullName );
				deleteExitsFile(delFile);
			}
		}
		FileUtil.copyFile(upload.getPath(), dstPath);//上传文件
		return fullName;
	}
	 
	private  void deleteExitsFile(File file) {
		if(file.exists() && file.isFile()){
			file.delete();
		}
	}
	
	/**
	 * 保存上传图片Action
	 */
	@Action(value="save-picture", results = { @Result(name = "redirect", location = "/common/upload/site-logo.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savePicture() {
		if(StringUtils.isNotBlank(siteLogoPhysicalPath)) {
			File file = new File(siteLogoPhysicalPath);
			deleteExitsFile(file);
		}
		String fileName = upload(url);
		//图片物理路径
		siteLogoPhysicalPath = FilePathSptUtil.UPLOAD_ROOT_PATH + FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
				FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
		//图片在数据库中存放的路径
		if("1".equals(upType)){
			siteLogoPhysicalPath = FilePathSptUtil.UPLOAD_ROOT_PATH + FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
			siteLogoDbPath = FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
		}else{
			siteBannerPhysicalPath = FilePathSptUtil.UPLOAD_ROOT_PATH + FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
			siteBannerDbPath = FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
		}
		
		return "redirect";
	}
	
	@Action(value="delete-excessPicture")
	public void deleteExcessPic() {
		File file = new File(siteLogoPhysicalPath);
		deleteExitsFile(file);
	}
	
	/**
	 * 查询站点（siteID,siteName）
	 * @return
	 */
	@Action(value="site-listsite")
	public String findAll(){
		List<Site> list = siteService.findALL(site);
		List<Site> siteList = new ArrayList<Site>();
		for(int i=0;i<list.size();i++){
			if(authLicence(ConstantOperCode.SITE_SITE, list.get(i).getSiteId())){
				Site site = list.get(i);
				siteList.add(site);
			}
		}
		Map<String,Object> map =new HashMap<String,Object>(); 
		 JSONObject json = new  JSONObject();
		 JSONArray jsonArray = new JSONArray();
		for(int i=0;i<siteList.size();i++){
			map.put("siteId", siteList.get(i).getSiteId());
			map.put("siteName", siteList.get(i).getSiteName());
			map.put("siteStatus", siteList.get(i).getSiteStatus());
			json = JSONObject.fromObject( map ); 
			jsonArray.add(json);
		}
		return renderText(jsonArray.toString());
	}
	/**
	 * 跳转启用界面
	 * @return
	 */
	@Action(value="status-but")
	public String startUsePage(){
		Site siteObj = siteService.getSite(site.getSiteId());
		siteName = siteObj.getSiteName();
		return SUCCESS;
	}
	
	/**
	 * 修改站点状态(禁用->启用)
	 * @return
	 */
	@Action(value="start-use",
			results={@Result(name="reload",type="redirectAction",params={"actionName","site-input"})})
	public String startUse(){
		if(StringUtils.isNotBlank(site.getSiteId())){
			Site siteEn = null;
			siteEn = siteService.getSite(site.getSiteId());
			Boolean status = new Boolean(true);
			siteEn.setSiteStatus(status);
			siteService.save(siteEn);
			addLog(Module.SITE.getValue(),OperAct.ENABLE.getValue(),site.getSiteId());
			 
		}
		return null;
	}
	
	/**
	 * 修改站点状态(启用->禁用)
	 * @return
	 */
	@Action(value="site-disable",
			results={@Result(name="reload",type="redirectAction",params={"actionName","status-but"})})
	public String disableUse(){
		if(StringUtils.isNotBlank(site.getSiteId())){
			Site siteEn = siteService.getSite(site.getSiteId());
			siteEn.setSiteStatus(false);
			siteService.save(siteEn);
			addLog(Module.SITE.getValue(),OperAct.DISABLE.getValue(),site.getSiteId());
			if(!siteEn.getSiteStatus()){
				saveMemoryHandle(siteEn.getSiteId());
			}
		}
		return RELOAD;
	}
	/**
	 * 站点名称唯一验证
	 * @return
	 */
	@Action(value="site-checknameunique")
	public String  checkNameUnique(){
		String text="";
		try{
			Boolean unique=siteService.checkNameUnique(site.getSiteName().trim(),stname);
			if(!unique){
				text="ok";
			}else{
				text="no";
			}
		}catch(Exception e){
			text="no";
		}
		return renderText(text);
	}
	/*
	 * 站点简称唯一验证
	 */
	@Action(value="site-checkSimplenameunique")
	public String checkSimplenameunique(){
		String text="";
		try {
			Boolean unique=siteService.checkSimplenameunique(site.getSiteShortName(),oldSimpleName);
			if(!unique){
				text="yes";
			}else{
				text="no";
			}
		} catch (Exception e) {
			 text="no";
		}
		return renderText(text);
	}
	
	/**
	 * 获取数据字典KEY值对应的NAME
	 * 
	 * @param key
	 * @param type
	 *            数据字典类型
	 * @return
	 */
	public String getName(String key,String code) {
		return dictionaryService.getDictionaryByDictionaryKey(key,code).getDictionaryValue();
	}
	
	@Action(value="site-loadallsite")
	public String loadAllSite(){
		List<Site> list = siteService.findALL(null);
		StringBuffer sb = new StringBuffer();
		sb.append("[");
		sb.append("{id:'0',name:'站点权限树',nocheck:true,open:true,isParent:true},");
		for(Site s : list){
			sb.append("{id:'").append(s.getSiteId()).append("',pId:'0',")
			  .append("name:'").append(s.getSiteName()).append("'},");		  
		}
		String json = sb.toString();
		if(json.endsWith(",")){
			json = json.substring(0, json.length()-1);
		}		 
		return renderText(json+"]");
	}
	
	/**
	 * 权限 展示
	 * @return
	 */
	@Action(value="site-loadalltopic")
	public String loadAllTopic(){
		String json = null;
		if(allSite){
			json = siteService.AllSiteTopicsJsonForAuth(null);			 
		}else{
			json = siteService.AllSiteTopicsJsonForAuth(getCurrentSiteId());
		}
		return 	renderText(json);

	}
	
	/**
	 * 保存站点首页模板
	 * @return
	 */
	@Action(value="site-saveindextpl")
	public String saveIndexTpl(){
		Site currentSite = (Site)getSessionValue(ConstantWebApp.CURRENT_SITE);
		String text = "";
		Site obj = siteService.getSite(currentSite.getSiteId());
		obj.setSiteIndexTpl(site.getSiteIndexTpl());
		siteService.save(obj);
		text = "ok";
		return renderText(text);
	}
	/**
	 * 显示站点首页
	 * @return
	 */
	@Action(value="site-index",results={@Result(name="success",location="/WEB-INF/content/site/site-index.jsp")}) 
	public String siteIndex(){
		
		return SUCCESS;
	}

	/**
	 * 获得站点首页模板
	 * @return
	 */
	@Action(value="site-getindextpl")
	public String getIndexTpl(){
		String text = "";
		Site obj = siteService.getSite(site.getSiteId());
		text = obj.getSiteIndexTpl();
		return renderText(text);
	}
	
	
	public String getSiteName() {
		return siteName;
	}

	public void setSiteName(String siteName) {
		this.siteName = siteName;
	}

	public String getStname() {
		return stname;
	}

	public void setStname(String stname) {
		this.stname = stname;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public String getOldSimpleName() {
		return oldSimpleName;
	}

	public void setOldSimpleName(String oldSimpleName) {
		this.oldSimpleName = oldSimpleName;
	}

	public List<Dictionary> getDicArea() {
		return dicArea;
	}

	public void setDicArea(List<Dictionary> dicArea) {
		this.dicArea = dicArea;
	}

	public String getCountryArea() {
		return countryArea;
	}

	public void setCountryArea(String countryArea) {
		this.countryArea = countryArea;
	}

	public String getProvinceArea() {
		return provinceArea;
	}

	public void setProvinceArea(String provinceArea) {
		this.provinceArea = provinceArea;
	}

	public String getCityArea() {
		return cityArea;
	}

	public void setCityArea(String cityArea) {
		this.cityArea = cityArea;
	}
	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public String getPic() {
		return pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	public String getPicTemp() {
		return picTemp;
	}

	public void setPicTemp(String picTemp) {
		this.picTemp = picTemp;
	}

	public List<Dictionary> getDicIsVirtualHosting() {
		return dicIsVirtualHosting;
	}

	public void setDicIsVirtualHosting(List<Dictionary> dicIsVirtualHosting) {
		this.dicIsVirtualHosting = dicIsVirtualHosting;
	}

	/**return 前端页面数据组装VO对象,<b>SiteBean</b>*/
	public SiteBean getSite() {
		return site;
	}

	public void setSite(SiteBean site) {
		this.site = site;
	}
	
	@SuppressWarnings("unchecked")
	@Action("sitetree")
	public String siteTree(){
		String adminId = null;
		if(allSite){
			adminId = DBInitId.CMS_SUPPER_ADMIN_ID;
		}else{
			adminId = getCurrentAdminId();				
		}		 
		Set<String> authSet = null;
		if(!DBInitId.CMS_SUPPER_ADMIN_ID.equals(adminId)){ 
			authSet = (Set<String>)getSessionValue(ConstantWebApp.CURRENT_ADMIN_AUTH_CODE);
		}
		Site currentSite = (Site)getSessionValue(ConstantWebApp.CURRENT_SITE);
		String path = getRequest().getContextPath();
		String json = siteService.hasAuthCodeCategories(authSet,
				currentSite.getSiteId(), adminId, type, currentSite.getSiteName(), path, needurl);	
 
		return renderText(json);
	}
	
	@Action("authsite")
	public String authsite(){		
		String json = siteService.AllSiteCategoriesJsonForAuth();		
		return renderText(json);
	}
	
	private boolean type;
	private boolean needurl;
	private boolean allSite;
	public boolean isNeedurl() {
		return needurl;
	}
	public void setNeedurl(boolean needurl) {
		this.needurl = needurl;
	}
	public boolean isType() {
		return type;
	}
	public void setType(boolean type) {
		this.type = type;
	}
	public boolean isAllSite() {
		return allSite;
	}
	public void setAllSite(boolean allSite) {
		this.allSite = allSite;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getSiteLogoDbPath() {
		return siteLogoDbPath;
	}
	public void setSiteLogoDbPath(String siteLogoDbPath) {
		this.siteLogoDbPath = siteLogoDbPath;
	}
	public String getSiteLogoPhysicalPath() {
		return siteLogoPhysicalPath;
	}
	public void setSiteLogoPhysicalPath(String siteLogoPhysicalPath) {
		this.siteLogoPhysicalPath = siteLogoPhysicalPath;
	}
	public String getUpType() {
		return upType;
	}
	public void setUpType(String upType) {
		this.upType = upType;
	}
	public String getSiteBannerDbPath() {
		return siteBannerDbPath;
	}
	public void setSiteBannerDbPath(String siteBannerDbPath) {
		this.siteBannerDbPath = siteBannerDbPath;
	}
	public String getSiteBannerPhysicalPath() {
		return siteBannerPhysicalPath;
	}
	public void setSiteBannerPhysicalPath(String siteBannerPhysicalPath) {
		this.siteBannerPhysicalPath = siteBannerPhysicalPath;
	}
	 
	 
}